<?php
namespace App\Http\Controllers\Client\Shop\Explore;

use App\Http\Controllers\ClientController;
use App\Models\Tools\Data;
use Illuminate\Support\Facades\DB;

class ExploreRepublishController extends ClientController
{
    /**
     * todo 过期订单重新发布(功能设计不完整，暂不启用)
     */
    public function index()
    {
        $all = $this->all;

        $eo_id = $all['eo_id'];
        $we_id = $this->we_id;

        // 验证订单是否已经过期
        $order_message = DB::table('explore_order')->where('eo_id', '=', $eo_id)->first();
        $order_message = json_decode(json_encode($order_message), true);
        $work_message = DB::table('explore_work')->where('eo_id', '=', $eo_id)->get()->toArray();
        $work_message = json_decode(json_encode($work_message, true));

        // 是否是发单人
        if ($order_message['we_id'] != $we_id){
            $this->setReturnJson(-1,'您不是这个订单的发单人');
        }
        // 全部接单的订单不能重发
        if(!in_array($order_message['status'], [Data::DATA_DB_EXPLORE_ORDER_STATUS_PARTIAL_SUCCESS, Data::DATA_DB_EXPLORE_ORDER_STATUS_FAILED])){
            $this->setReturnJson(-1,'订单状态正常，不能重发');
        }
        // 结束状态的订单，查询当前订单数量
        if($order_message['status'] === Data::DATA_DB_EXPLORE_ORDER_STATUS_FINISHED){
//            if($order_message[''])
        }

    }

}
